package com.hontech.pastacooking.net

import com.hontech.pastacooking.app.NetTask

class WriteTask (private val socket: NIOSocket, val frame: ByteArray) : Runnable {

    companion object {

        fun write(socket: NIOSocket, frame: ByteArray) {
            NetTask.post( WriteTask(socket, frame) )
        }
    }

    override fun run() {

        try {
            exec()
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    private fun exec() {
        socket.write(frame)
    }
}

